<form class="layui-form seller-form"  action="" >
    <div class="layui-form-item" style="margin-bottom:0;">

    </div>
</form>
<div class="table-body">
    <table id="setting" lay-filter="setting"></table>
</div>



<script type="text/html" id="btn">
    <a class="layui-btn layui-btn-xs edit-class" lay-event="xg" >修改</a>
</script>
<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
	
        layui.table.render({
            elem: '#setting',
            height: 'full-330',
            cellMinWidth: '80',
            page: 'true',
            limit:'20',
            url: "{:url('Setting/setting')}?_ajax=1",
            id:'setting',
            cols: [[
                {field:'skey', width:200,title:'类型',templet: function(data){
                        if(data.skey == 'chongzhi_msg'){
                            return '<span>钱包页面提示语</span>';
                        }else if(data.skey == 'chongzhi_pwd'){
                            return '<span>充值密码</span>';
                        }else if(data.skey == 'da_chongzhi_msg'){
                            return '<span>充值提示语</span>';
                        }else if(data.skey == 'kefu_mobile'){
                            return '<span>客服电话</span>';
                        }else{
                            return '<span>未知</span>';
                        }
                }},
                {field:'value', width:320,title:'当前值',templet: function(data){
                        if(data.skey == 'chongzhi_pwd'){
                            return '<span>********</span>';
                        }else{
                            return data.value;
                        }
                }},
                {field: 'operating', title: '操作', width:100, align: 'center', fixed: 'right', toolbar: '#btn'},
            ]]
        });

        layui.form.on('submit(*)', function(data){
            layui.table.reload('setting', {
                where: data.field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //查看操作
		layui.table.on('tool(setting)', function(obj){
			var data = obj.data;
			console.log(data)
			if(obj.event == 'xg') {
				layer.prompt({
				  value: data.value,
				  title: '修改配置',
				}, function(value, index, elem){
					$.ajax({
						type:'post',
						url: "{:url('edit')}",
						data:{
							skey: data.skey,
							value: value
						},
						success:function(e){
							if(e.status){
								layer.msg('编辑成功');
								layui.table.reload('setting', {
									where: data.field
									,page: {
										curr: 1 //重新从第 1 页开始
									}
								});
								layer.close(index);
							}else{
								layer.msg(e.msg);
							}
						}
					})
				});
			}
		})
        $(document).on('click','.option-view',function(){
			layer.prompt({
			  formType: 1,
			  value: '初始值',
			  title: '修改配置',
			}, function(value, index, elem){
			  alert(value); //得到value
			  layer.close(index);
			});
            /*$.ajax({
                type:'get',
                url: "{:url('billPayments/view')}",
                data:'payment_id='+$(this).attr('data-id'),
                success:function(e){
                    if(e.status){
                        window.box = layer.open({
                            type: 1,
                            content: e.data,
                            area: ['600px', '600px'],
                            title:'支付单查看'
                        });
                    }else{
                        layer.msg(e.msg);
                    }

                }
            });*/
        });
    });
</script>
